package ro.isdc.training.jpa.systemuser.domain;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;

import ro.isdc.training.jpa.misc.domain.BusinessEntity;

/**
 * Describes a role of a system user
 * 
 * @author Andrei Chirila
 */
@javax.persistence.Entity
@Table(name = "SYSTEM_USER_ROLES")
@AttributeOverrides( {
		@AttributeOverride(name = "entityId", column = @Column(name = "ROLEID")),
		@AttributeOverride(name = "versionNo", column = @Column(name = "ROLEVERSNO")) })
public class SystemUserRole extends BusinessEntity {

	/**
	 * Generated Serial Version UID
	 */
	private static final long serialVersionUID = -5858035716917352950L;

	@Enumerated(EnumType.STRING)
	@Column(name = "role")
	private UserRole rolename;

	/**
	 * @return the role
	 */
	public UserRole getRolename() {
		return rolename;
	}

	/**
	 * @param role
	 *          the role to set
	 */
	public void setRolename(final UserRole role) {
		this.rolename = role;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("rolename", this.rolename).append(
				"entityId", this.getEntityId()).append("versionNo", this.versionNo)
				.append("creationTimeStamp", this.creationTimestamp).append(
						"lastUpdateTimestamp", this.lastUpdateTimestamp).toString();
	}
}
